package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Daily;
import cn.wolfcode.trip.base.domain.DailyContent;
import cn.wolfcode.trip.base.query.DailyQueryObject;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IDailyService;
import cn.wolfcode.trip.base.util.QiniuCloudUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.rmi.server.InactiveGroupException;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/dailys")
public class DailyController {
    @Autowired
    private IDailyService service;


    @GetMapping
    public Object list(DailyQueryObject qo,Integer sign) {
        if(qo.getState()==2){
            qo.setPageSize(0);
        }
        if(sign != null && sign == 1){
            qo.setPageSize(0);
            qo.setOrderBy("schedule desc");
        }
        PageInfo<Daily> daily = service.selectBySchedule(qo);
        return daily;
    }


    @GetMapping("/{id}")
    public Object getContent(@PathVariable Long id){
        Daily daily = service.selectByPrimaryKey(id);
        return daily;
    }



}
